home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / mawk10.zip / NOTES < prev    next >
Text File  |  1991-10-05  |  5KB  |  123 lines

  1.  
  2. Notes for MsDOS
  3. ---------------
  4.  
  5. For a number of reasons, entering a mawk program on the command line 
  6. using command.com as your shell is an exercise in futility, so under 
  7. MsDOS the command syntax is 
  8.  
  9.     mawk [-Fs] optional_list_of_files
  10.  
  11. You'll get a prompt, and then type in the program.  The -f option works 
  12. as before.  
  13.  
  14. If you use a DOS shell that gives you a Unix style command line, to use 
  15. it you'll need to provide a C function reargv() that retrieves argc and 
  16. argv[] from your shell.
  17.  
  18. Some features are missing from the DOS version of mawk: No system(), and
  19. no input or output pipes.  To provide a hook to stderr, I've added 
  20.  
  21.     errmsg( "string" )
  22.  
  23. which prints "string\n" to stderr which will be the console and only the
  24. console under command.com.  A better solution would be to associate a 
  25. file with handle 2, so print and printf would be available.  Consider 
  26. the errmsg() feature as temporary.  
  27.  
  28. For compatibility with Unix, CR are silently stripped from input and LF 
  29. silently become CRLF on output.  
  30.  
  31. WARNING: If you write an infinite loop that does not print to the 
  32. screen, then you will have to reboot.  For example 
  33.  
  34.     x = 1 
  35.     while( x < 10 )  A[x] = x
  36.     x++
  37.  
  38. By mistake the x++ is outside the loop.  What you need to do is type 
  39. control break and the keyboard hardware will generate an interrupt and 
  40. the operating system will service that interrupt and terminate your 
  41. program, but unfortunately MsDOS does not have such a feature.  
  42.  
  43.  
  44. how to make mawk under MsDOS
  45. ---------------------------
  46.  
  47. I've provided four .bat files that make mawk with TurboC.
  48. An anonymous reviewer provided a makefile that works with
  49. MSC 6.0A and nmake.
  50.  
  51. Assuming you keep the same directory structure:
  52.  
  53.  
  54. 1)  If you want a Unix style command line for mawk, you'll need to
  55.     write a function called reargv(int *, char ***) which passes
  56.     mawk the modified argc and argv via reargv(&argc,&argv).
  57.     Put it in a file called reargv.c
  58.  
  59.     The supplied reargv.c works with POLYSHELL by Polytron; for a
  60.     different shell you could use it as an example.
  61.     (I've looked at the MKS documentation and writing reargv() for
  62.      MKS ksh would be easy.  (contributions welcome)).
  63.  
  64. 2)  Using TurboC++
  65.    small.bat -- makes small model without reargv
  66.    vsmall.bat -- makes small model with reargv
  67.    large.bat -- makes large model without reargv
  68.    vlarge.bat -- makes large model with reargv
  69.  
  70.    You need to replace the LIB in the tlink command with the
  71.    directory that holds your C library. 
  72.  
  73.    move the .bat file to mawk directory and run it.
  74.  
  75. 3) Using MSC , move Makefile.MSC to mawk directory and
  76.    run nmake -- makes both small and large model
  77.  
  78. 4)  YACC --
  79. Take some care that you don't trash parse.[ch] unless you're
  80. sure you want to remake them.
  81. (If using a make, also check that the date of parse.c is
  82. newer than parse.y or parse2.xc)
  83. If you don't change parse.y, the parse.c and parse.h provided
  84. were made with Berkeley yacc and can be redistributed and you
  85. don't need a yacc.  The executables look bigger than before,
  86. but I reuse the parser table memory which returns 15K to the
  87. mem pool.
  88.  
  89. 5)  Large model DOS has been built and tested with this code.
  90. Compiled with TurboC its about 33% slower.  I use two mawk's,
  91. a small model called mawk and a large model called bmawk.
  92. For real work I hardly ever need bmawk.
  93.  
  94. 6)  The same test suite that is run on mawk under Unix can now
  95. be run under DOS.  The same anonymous reviewer wrote  batch
  96. files mawk_tes.bat and fpe_test.bat.  To use them copy or move
  97. all the files in msdos/dostest to mawk/test.
  98.  
  99. ==================================================================
  100.  
  101. The reason system() and pipes are missing is I haven't decided
  102. entirely how to handle the runaway loop problem.  Dos makes
  103. asynchronous termination of a program difficult, because DOS
  104. itself might not be able to handle exit().
  105.  
  106. Hooking int 0x1a forces me to deal with cleanup and makes ^C
  107. a pain.  What is the effect of my 0x1a on children? (That's why
  108. no system() or pipes yet).  What do I have to check after a child
  109. terminates, children can muck up the state of the parent process.
  110.  
  111.  
  112. I have used mawk as is on DOS for about 6 months, what's missing
  113. I rarely use  except to emit error messages and I use
  114. errmsg() for that.  If I stall about fixing this stuff, DOS
  115. might go away and I'll never have to deal with it.
  116.  
  117. Note added 8/8/91 -- I'll probably never fix the runaway loop stuff
  118. and ignore the fact that children can damage the parent under DOS.
  119. Then system and pipes are easy -- someone should do it.
  120.  
  121. Note added 9/12/91 -- It's not easy to stay within 64K and add
  122. system() and pipes().  In the next release of mawk, I'll do it.
  123.